#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int n;
vector<int> v[200003];
int fa[200003],dep[200003];
int f[200003][2],nxt[200003],tag[200003];
int siz[200003],mi[200003];
inline void tms(int p,long long k)
{
	for(int op = 0;op < 2;op++)
		f[p][op] = f[p][op] * k % mod;
	tag[p] = tag[p] * k % mod;
}
inline void pushdown(int p)
{
	tms(nxt[p],tag[p]);
	tag[p] = 1;
}
void DFS1(int p)
{
	dep[p] = 1,nxt[p] = n + 1;
	siz[p] = 1;
	for(auto i:v[p])
	{
		DFS1(i),siz[p] += siz[i];
		if(dep[i] >= dep[nxt[p]])
			nxt[p] = i;
	}
	dep[p] = dep[nxt[p]] + 1;
}
void DFS2(int p)
{
	tag[p] = 1;
	if(nxt[p] <= n)
		DFS2(nxt[p]);
	int mx = n + 1;
	for(auto i:v[p]) if(i != nxt[p])
	{
		DFS2(i);
		if(dep[i] > dep[mx])
			mx = i;
		int d = nxt[p];
		for(int x = i;x <= n;x = nxt[x],d = nxt[d])
		{
			f[d][1] = 1ll * f[d][0] * f[x][1] % mod + 1ll * f[d][1] * f[x][0] % mod;
			f[d][0] = 1ll * f[d][0] * f[x][0] % mod;
			pushdown(d),pushdown(x);
		}
		tms(d,mi[siz[i]]);
	}
	long long C = mi[siz[p] - 1];
	for(int x = mx,y = nxt[p];x <= n;x = nxt[x],y = nxt[y])
		f[y][0] = (C + mod - f[y][1]) % mod,pushdown(y);
	tag[p] = 2,f[p][0] = f[p][1] = mi[siz[p] - 1];
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);
	cin >> n;
	for(int i = 1;i <= n;i++)
		cin >> fa[i],v[fa[i]].push_back(i);
	mi[0] = 1;
	for(int i = 1;i <= n + 1;i++)
		mi[i] = (mi[i - 1] << 1) % mod;
	DFS1(0);
	DFS2(0);
	long long ans = 0;
	for(int p = 0;p <= n;p = nxt[p])
		ans += f[p][1],pushdown(p);
	cout << ans % mod;
	return 0;
}